#!/bin/bash

# get_depends作用:将一个可执行程序所依赖的库复制一份到指定目录
# 传递两个参数
# 1.可执行程序的路径名
# 2.一个存放上一个参数传递的路径名所依赖的库的存储目录

declare depends
get_depends()
{
    depends=$(ldd $1 | awk '{if (match($3,"/")){print $3}}')
    mkdir -p $2
    cp -Lr $depends $2
}

get_depends ./speech/build/speech_server        ./speech/depends
get_depends ./file/build/file_server            ./file/depends
get_depends ./user/build/user_server            ./user/depends
get_depends ./transmit/build/transmit_server    ./transmit/depends
get_depends ./message/build/message_server      ./message/depends
get_depends ./friend/build/friend_server        ./friend/depends
get_depends ./gateway/build/gateway_server      ./gateway/depends

cp /bin/nc ./speech/
cp /bin/nc ./file/
cp /bin/nc ./user/
cp /bin/nc ./transmit/
cp /bin/nc ./message/
cp /bin/nc ./friend/
cp /bin/nc ./gateway/

get_depends /bin/nc ./speech/depends
get_depends /bin/nc ./file/depends
get_depends /bin/nc ./user/depends
get_depends /bin/nc ./transmit/depends
get_depends /bin/nc ./message/depends
get_depends /bin/nc ./friend/depends
get_depends /bin/nc ./gateway/depends




